function loginSubmit()
{
	var user = $("#loginEmail").val();
	var pass = $("#loginPass").val();
	
	var data = "user="+user+"&pass="+pass+"&action=login";
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#loginError").html(html);         
		}      
	});
}

function registerSubmit()
{
	var name = $("#registerName").val();
	var user = $("#registerEmail").val();
	var pass = $("#registerPass").val();
	
	var data = "name="+name+"&user="+user+"&pass="+pass+"&action=register";
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#registerError").html(html);         
		}      
	});
}

function msgSubmit()
{
	var message = $("#message").val();
	
	
	var data = "message="+message+"&action=msgsubmit";
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#mess").html(html);         
		}      
	});
}

function submitmandatoryData()
{
	var city = $("#city").val();
	var dob = $("#dob").val();
	var gender = $("#gender").val();
	
	var data = "city="+city+"&dob="+dob+"&gender="+gender+"&action=submitmandatoryData";
		$.ajax({
		
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#registerError").html(html);
			//alert('hii');      
		}      
	});
}



function editProfile()
{
var city = $("#city").val();
var dob = $("#dob").val();
var gender = $("#gender").val();
var rstatus = $("#rstatus").val();
var country = $("#country").val();
var about = $("#about").val();
var data = "city="+city+"&dob="+dob+"&gender="+gender+"&rstatus="+rstatus+"&country="+country+"&about="+about+"&action=editProfile";

$.ajax({
//this is the php file that processes the data
url: "index.php",

//POST method is used
type: "POST",

//pass the data
data: data,

//Do not cache the page
cache: false,

//success
success: function (html) {
alert('share successfully');
}
});
}


function statusUpdate()
{
	var status = $("#statusVal").val();
	var privacy = $('input:radio[name=Radio11]:checked').val();
	var data = "status="+status+"&action=statusUpdate&privacy="+privacy;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {
			$("#statusError").fadeIn();
			$("#statusVal").val('');
			$("#statusError").html(html);
			$("#statusError").fadeOut(5000);
			
			$('#statusList').prepend($("<div class='maincmtbox'><div class='topholder'><div class='cname'><a href='' class='linkname'><?php echo $_SESSION['fullname']; ?></a></div></div><div class='cmtbox'></div><div class='cmntbox'>"+status+"</div><div class='ldscbox'><spna class='spn'><a href='#a'>Like</a></spna><spna class='spn'><a href='#a'>Dislike</a></spna><spna class='spn'><a href='#a'>Share</a></spna><spna class='spn'><a href='#a' onclick='$(\"#comment\").focus();'>Comment</a></spna><div class='cnamedetails'>"+privacy+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 minutes ago <a href=''></a></div></div></div><div class='subcommented'></div><div class='subcomment'><div class='commenta'><div class='cmtboxsub'></div><textarea id='comment' cols='20' rows='1' class='textareainner' placeholder='Write here !!!'></textarea></div></div>").hide().fadeIn('slow'));
		}      
	});
}

function logout()
{
	var data = "action=logout";
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			location.reload();
		}      
	});
}

function showWall()
{
	var data = "action=showwall&id="+statusId;
	alert('hii');
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#wallDetail").html(html);
		}      
	});
}


function showComment(statusId)
{
	var data = "action=showComment&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#commentbox"+statusId).html(html);
		}      
	});
}

function showReply(commentId)
{
	var data = "action=showReply&id="+commentId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#subcommentBox"+commentId).html(html);
		}      
	});
}

function sendReply(commentId)
{
	var text = $("#subcommentarea"+commentId).val();
	var data = "action=sendReply&id="+commentId+"&text="+text;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {    
			$("#subcommentBox"+commentId).append($(html).hide().fadeIn('slow'));
			$("#subcommentarea"+commentId).val('');
			var reply = $("#commentReply"+commentId).html();
			reply++;
			$("#commentReply"+commentId).html(reply);
		}      
	});
}

function sendComment(statusId)
{
	var text = $("#comment"+statusId).val();
	var data = "action=sendComment&id="+statusId+"&text="+text;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			$("#commentbox"+statusId).append($(html).hide().fadeIn('slow'));
			$("#comment"+statusId).val('');
			var comment = $("#statusComment"+statusId).html();
			comment++;
			$("#statusComment"+statusId).html(comment);
		}      
	});
}

function likeStatus(statusId)
{
	var data ="action=likeStatus&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#statusLike"+statusId).html();
			likeCount++;
			var dislikeCount = $("#statusDislike"+statusId).html();
			$("#like"+statusId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='unlikeStatus("+statusId+")'>Like-</a><span id='statusLike"+statusId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#dislike"+statusId).html("<span class='spn spancount'>Dislike-<span id='statusDislike"+statusId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function unlikeStatus(statusId)
{
	var data ="action=unlikeStatus&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#statusLike"+statusId).html();
			likeCount--;
            var dislikeCount = $("#statusDislike"+statusId).html();                                                    
			$("#like"+statusId).html("<span class='spn'><a href='#a' onclick='likeStatus("+statusId+")'>Like-</a><span id='statusLike"+statusId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#dislike"+statusId).html("<span class='spn'><a href='#a' onclick='dislikeStatus("+statusId+")'>Dislike-</a><span id='statusDislike"+statusId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function dislikeStatus(statusId)
{
	var data ="action=dislikeStatus&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {
			var likeCount =  $("#statusLike"+statusId).html();
			var dislikeCount = $("#statusDislike"+statusId).html();
			dislikeCount++;
			$("#like"+statusId).html("<span class='spn spancount'>Like-<span id='statusLike"+statusId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#dislike"+statusId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='undislikeStatus("+statusId+")'>Dislike-</a><span id='statusDislike"+statusId+"' class='spancount'>"+dislikeCount+"</span></span>");	
		}
	});
}

function undislikeStatus(statusId)
{
	var data ="action=undislikeStatus&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount =  $("#statusLike"+statusId).html();
			var dislikeCount = $("#statusDislike"+statusId).html();
			dislikeCount--;
			
			$("#like"+statusId).html("<span class='spn'><a href='#a' onclick='likeStatus("+statusId+")'>Like-</a><span id='statusLike"+statusId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#dislike"+statusId).html("<span class='spn'><a href='#a' onclick='dislikeStatus("+statusId+")'>Dislike-</a><span id='statusDislike"+statusId+"' class='spancount'>"+dislikeCount+"</span></span>");
			}      
	});
}



function likeComment(commentId)
{
	var data ="action=likeComment&id="+commentId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#commentLike"+commentId).html();
			likeCount++;
			var dislikeCount = $("#commentDislike"+commentId).html();
			$("#commentlike"+commentId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='unlikeComment("+commentId+")'>Like-</a><span id='commentLike"+commentId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#commentdislike"+commentId).html("<span class='spn spancount'>Dislike-<span id='commentDislike"+commentId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function unlikeComment(commentId)
{
	var data ="action=unlikeComment&id="+commentId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#commentLike"+commentId).html();
			likeCount--;
            var dislikeCount = $("#commentDislike"+commentId).html();
			$("#commentlike"+commentId).html("<span class='spn'><a href='#a' onclick='likeComment("+commentId+")'>Like-</a><span id='commentLike"+commentId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#commentdislike"+commentId).html("<span class='spn'><a href='#a' onclick='dislikeComment("+commentId+")'>Dislike-</a><span id='statusDislike"+commentId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function dislikeComment(commentId)
{
	var data ="action=dislikeComment&id="+commentId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {
			var likeCount =  $("#commentLike"+commentId).html();
			var dislikeCount = $("#commentDislike"+commentId).html();
			dislikeCount++;
			$("#commentlike"+commentId).html("<span class='spn spancount'>Like-<span id='commentLike"+commentId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#commentdislike"+commentId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='undislikeComment("+commentId+")'>Dislike-</a><span id='commentDislike"+commentId+"' class='spancount'>"+dislikeCount+"</span></span>");	
		}
	});
}

function undislikeComment(commentId)
{
	var data ="action=undislikeComment&id="+commentId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount =  $("#commentLike"+commentId).html();
			var dislikeCount = $("#commentDislike"+commentId).html();
			dislikeCount--;
			
			$("#commentlike"+commentId).html("<span class='spn'><a href='#a' onclick='likeComment("+commentId+")'>Like-</a><span id='commentLike"+commentId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#commentdislike"+commentId).html("<span class='spn'><a href='#a' onclick='dislikeComment("+commentId+")'>Dislike-</a><span id='commentDislike"+commentId+"' class='spancount'>"+dislikeCount+"</span></span>");
			}      
	});
}


function likeReply(replyId)
{
	var data ="action=likeReply&id="+replyId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#replyLike"+replyId).html();
			likeCount++;
			var dislikeCount = $("#replyDislike"+replyId).html();
			$("#replylike"+replyId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='unlikeReply("+replyId+")'>Like-</a><span id='replyLike"+replyId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#replydislike"+replyId).html("<span class='spn spancount'>Dislike-<span id='commentDislike"+replyId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function unlikeReply(replyId)
{
	var data ="action=unlikeReply&id="+replyId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount = $("#replyLike"+replyId).html();
			likeCount--;
            var dislikeCount = $("#commentDislike"+replyId).html();                                                    
			$("#replylike"+replyId).html("<span class='spn'><a href='#a' onclick='likeReply("+replyId+")'>Like-</a><span id='replyLike"+replyId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#replydislike"+replyId).html("<span class='spn'><a href='#a' onclick='dislikeReply("+replyId+")'>Dislike-</a><span id='statusDislike"+replyId+"' class='spancount'>"+dislikeCount+"</span></span>");
		}      
	});
}

function dislikeReply(replyId)
{
	var data ="action=dislikeReply&id="+replyId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) {
			var likeCount =  $("#replyLike"+replyId).html();
			var dislikeCount = $("#replyDislike"+replyId).html();
			dislikeCount++;
			alert(dislikeCount);
			$("#replylike"+replyId).html("<span class='spn spancount'>Like-<span id='replyLike"+replyId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#replydislike"+replyId).html("<span class='spn'><img src='view/img/icons/Tick.png'><a href='#a' onclick='undislikeReply("+replyId+")'>Dislike-</a><span id='replyDislike"+replyId+"' class='spancount'>"+dislikeCount+"</span></span>");	
		}
	});
}

function undislikeReply(replyId)
{
	var data ="action=undislikeReply&id="+replyId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			var likeCount =  $("#replyLike"+replyId).html();
			var dislikeCount = $("#replyDislike"+replyId).html();
			dislikeCount--;
			
			$("#replylike"+replyId).html("<span class='spn'><a href='#a' onclick='likeReply("+replyId+")'>Like-</a><span id='replyLike"+replyId+"' class='spancount'>"+likeCount+"</span></span>");
			$("#replydislike"+replyId).html("<span class='spn'><a href='#a' onclick='dislikeReply("+replyId+")'>Dislike-</a><span id='replyDislike"+replyId+"' class='spancount'>"+dislikeCount+"</span></span>");
			}      
	});
}





function shareDoc(statusId)
{
	var data ="action=shareStatus&id="+statusId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			alert('share successfully');
			//$("#likeStatus"+statusId).css('color','red');
			//$("#likeStatus"+statusId).disabled();
		}      
	});
}

function showPersonal()
{
	$("#personal").show();
	$("#education").hide();
	$("#work").hide();
	$("#interest").hide();
	$("#contact").hide();
}

function showEducation()
{
	$("#personal").hide();
	$("#education").show();
	$("#work").hide();
	$("#interest").hide();
	$("#contact").hide();
}

function showWork()
{
	$("#personal").hide();
	$("#education").hide();
	$("#work").show();
	$("#interest").hide();
	$("#contact").hide();
}

function showInterest()
{
	$("#personal").hide();
	$("#education").hide();
	$("#work").hide();
	$("#interest").show();
	$("#contact").hide();
}

function showContact()
{
	$("#personal").hide();
	$("#education").hide();
	$("#work").hide();
	$("#interest").hide();
	$("#contact").show();
}

function showFriendsPage(userId)
{
	parent.redirectToFriend(userId);

	
}

function redirectToFriend(userId)
{
	
	var data ="action=showFriendPage&id="+userId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
				parent.$.fancybox.close();
			
		}      
	});
}



function sendMsg(userId)
{
	
	var data ="action=sendMsg&id="+userId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
				parent.$.fancybox.close();
			
		}      
	});
}


function addUserAsFriend(userId)
{
	var data ="action=addAsFriend&id="+userId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			alert("added as friend");
		}      
	});
}

function sendFriendRequest(userId)
{
	var data ="action=sendFriendRequest&id="+userId;
	$.ajax({
		//this is the php file that processes the data
		url: "index.php",
		 
		//POST method is used
		type: "POST",
	
		//pass the data
		data: data,    
		 
		//Do not cache the page
		cache: false,
		 
		//success
		success: function (html) { 
			$("#sendrequest").html("Friend request sent");
		}      
	});

}
